Start up functions

Read and organize data

read_srm_export <- function(filename, columns = c("peak_name", "RT.min", "basepeak", "area.cpm", "height.cts", "quantitation")) {
  filename %>% 
    # read excel files
    read_excel(sheet = "Integration", skip = 42, 
               col_names = columns, col_types = rep("text", length(columns))) %>% 
    as_data_frame() %>%
    # remove empty rows
    filter(!is.na(peak_name), peak_name != "n.a.") %>% 
    # convert the relevant numeric columns into numbers
    mutate_at(vars(RT.min, area.cpm, height.cts), as.numeric) %>% 
    # remove useless columns
    select(-basepeak, -quantitation) %>% 
    # add filename info
    mutate(file_id = gsub("\\.xls", "", basename(filename))) %>% 
    select(file_id, everything())
}

# get data
all_data <- 
  # find all excel files ##change name and use new folder for new project
  list.files("data_SH1", recursive = TRUE, full.names = TRUE, pattern = "\\.xls$") %>% 
  # send them to the read method
  lapply(read_srm_export) %>% 
  # combine the data set
  bind_rows() %>% 
  # pull out sample information
  #mutate(sample_id = str_match(all_data$file_id, "TSQ\\d+_GB_(.*)$") %>% { .[,2] }) %>% 
  # get n replicates
  group_by(file_id)
  #mutate(n_replicates = length(unique(file_id)))

File names for metadata file

Calculation peak amounts and rock concentrations, ID standards

depth_and_rock_info <- read_excel(file.path("metadata", "aliphaticSRM_SH1.xlsx")) %>% 
  rename(tle = `TLE.mg`, maltene = `maltenes.mg`, ref_amount_added.ug = `D4.ug` )%>% 
  filter(!is.na(file_id)) %>%
  filter (process == "yes")
depth_and_rock_info
## # A tibble: 69 x 8
##    file_id       OG depth rock.g      tle maltene ref_amount_adde… process
##    <chr>      <dbl> <dbl>  <dbl>    <dbl>   <dbl>            <dbl> <chr>  
##  1 TSQ3481_G…  2.00   125  10.0    24.9     13.7               100 yes    
##  2 TSQ3482_G…  3.00   124  10.1   224        7.30              100 yes    
##  3 TSQ3483_G…  4.00   123  10.3  - 14.4      5.00              100 yes    
##  4 TSQ3484_G…  5.00   122   9.28    3.20     5.40              100 yes    
##  5 TSQ3485_G…  6.00   121  10.6    33.4     NA                 100 yes    
##  6 TSQ3486_G…  7.00   119   9.62 -214        4.80              100 yes    
##  7 TSQ3489_G…  8.00   118   9.70    3.40     5.00              100 yes    
##  8 TSQ3490_G…  9.00   117  10.7     5.00     6.30              100 yes    
##  9 TSQ3491_G… 10.0    115  11.1     5.00     6.00              100 yes    
## 10 TSQ3492_G… 11.0    114  10.2     0.400    6.90              100 yes    
## # ... with 59 more rows
data_by_depth <- 
  all_data %>%
  left_join(depth_and_rock_info, by = "file_id") %>% 
  group_by(file_id) %>% 
  mutate(
    n_peaks = n(),
    n_standards = sum(peak_name == "D4 C29 ISTD"),
    ref_area.cpm = area.cpm[peak_name == "D4 C29 ISTD"],
    amount.ug = area.cpm/ref_area.cpm * ref_amount_added.ug,
   
    #Normalize by what you want
    conc_rock.ug_g = amount.ug / rock.g, 
    conc_tle.ug.g = amount.ug / tle,  
    conc_maltene.ug.g = amount.ug / maltene
    
  )%>% ungroup() %>% 
  arrange(file_id, peak_name) 

data_by_depth
## # A tibble: 11,665 x 19
##    file_id  peak_name  RT.min area.cpm height.cts    OG depth rock.g   tle
##    <chr>    <chr>       <dbl>    <dbl>      <dbl> <dbl> <dbl>  <dbl> <dbl>
##  1 TSQ3466… 20R 4a,24…   34.7    42909     396389  22.0   102   11.0  4.50
##  2 TSQ3466… 20R, 4a M…   33.4    33439     425331  22.0   102   11.0  4.50
##  3 TSQ3466… 20R, 4a M…   32.8    49529     763046  22.0   102   11.0  4.50
##  4 TSQ3466… 20R, 4a,2…   35.3    26212     404760  22.0   102   11.0  4.50
##  5 TSQ3466… 20S, 4a M…   32.1    49207     882869  22.0   102   11.0  4.50
##  6 TSQ3466… 20S, 4a,2…   35.8    31831     268610  22.0   102   11.0  4.50
##  7 TSQ3466… 20S, 4a,2…   34.0    51613     456842  22.0   102   11.0  4.50
##  8 TSQ3466… 25-nor C2…   37.6    11915     155542  22.0   102   11.0  4.50
##  9 TSQ3466… 28, 30 C2…   37.0    27403     343070  22.0   102   11.0  4.50
## 10 TSQ3466… 29, 30 C2…   35.8     5780      63220  22.0   102   11.0  4.50
## # ... with 11,655 more rows, and 10 more variables: maltene <dbl>,
## #   ref_amount_added.ug <dbl>, process <chr>, n_peaks <int>,
## #   n_standards <int>, ref_area.cpm <dbl>, amount.ug <dbl>,
## #   conc_rock.ug_g <dbl>, conc_tle.ug.g <dbl>, conc_maltene.ug.g <dbl>

Calculate Recovery

Linear regressions of the calibration curves

standard <- read_excel(file.path("metadata", "D4_calibration.xlsx"))   ###read excel

###calibration curve
standard %>% 
  ggplot() +
  aes(x = Known.ng, y = Measured_area.counts, color = calibration) + 
  geom_smooth(method = "lm", alpha = 0.5) +
  geom_point() +
  theme_bw() +
  theme(legend.position = "none") 

calibrations <- 
  standard %>% 
  filter(!is.na(calibration)) %>% 
  nest(-calibration) %>% 
  mutate(
    fit = map(data, ~summary(lm(`Measured_area.counts`~ `Known.ng`, data = .x))),
    coefficients = map(fit, "coefficients"),
    intercept = map_dbl(coefficients, `[`, 1, 1),
    intercept_se = map_dbl(coefficients, `[`, 1, 2),
    slope = map_dbl(coefficients, `[`, 2, 1),
    slope_se = map_dbl(coefficients, `[`, 2, 2),
    r2 = map_dbl(fit, "r.squared")
  )

calibrations %>% select(-data, -fit, -coefficients) %>% knitr::kable(d = 3)
calibration intercept intercept_se slope slope_se r2
jan2018 705.862 1371.146 72929.67 3337.256 0.996

Determine yield

These numbers are not useful for anything else.

calib_data <-
  data_by_depth %>% 
  # temp
  mutate(calibration = "jan2018") %>% 
  left_join(calibrations, by = "calibration") %>% 
  mutate(
    total_volume.uL = 100,
    total_inject.uL = 1.5,
    ref_amount_inject_expected.ng = (ref_amount_added.ug * 1000)/total_volume.uL * total_inject.uL ,
    ref_amount_inject_measured.ng = (ref_area.cpm - intercept)/slope,
    ref_amount_measured.ug = ((total_volume.uL* ref_amount_inject_measured.ng)/total_inject.uL) * 1/1000,
    yield = (ref_amount_inject_measured.ng/ref_amount_inject_expected.ng) * 100
  )
  
calib_data
## # A tibble: 11,665 x 34
##    file_id  peak_name  RT.min area.cpm height.cts    OG depth rock.g   tle
##    <chr>    <chr>       <dbl>    <dbl>      <dbl> <dbl> <dbl>  <dbl> <dbl>
##  1 TSQ3466… 20R 4a,24…   34.7    42909     396389  22.0   102   11.0  4.50
##  2 TSQ3466… 20R, 4a M…   33.4    33439     425331  22.0   102   11.0  4.50
##  3 TSQ3466… 20R, 4a M…   32.8    49529     763046  22.0   102   11.0  4.50
##  4 TSQ3466… 20R, 4a,2…   35.3    26212     404760  22.0   102   11.0  4.50
##  5 TSQ3466… 20S, 4a M…   32.1    49207     882869  22.0   102   11.0  4.50
##  6 TSQ3466… 20S, 4a,2…   35.8    31831     268610  22.0   102   11.0  4.50
##  7 TSQ3466… 20S, 4a,2…   34.0    51613     456842  22.0   102   11.0  4.50
##  8 TSQ3466… 25-nor C2…   37.6    11915     155542  22.0   102   11.0  4.50
##  9 TSQ3466… 28, 30 C2…   37.0    27403     343070  22.0   102   11.0  4.50
## 10 TSQ3466… 29, 30 C2…   35.8     5780      63220  22.0   102   11.0  4.50
## # ... with 11,655 more rows, and 25 more variables: maltene <dbl>,
## #   ref_amount_added.ug <dbl>, process <chr>, n_peaks <int>,
## #   n_standards <int>, ref_area.cpm <dbl>, amount.ug <dbl>,
## #   conc_rock.ug_g <dbl>, conc_tle.ug.g <dbl>, conc_maltene.ug.g <dbl>,
## #   calibration <chr>, data <list>, fit <list>, coefficients <list>,
## #   intercept <dbl>, intercept_se <dbl>, slope <dbl>, slope_se <dbl>,
## #   r2 <dbl>, total_volume.uL <dbl>, total_inject.uL <dbl>,
## #   ref_amount_inject_expected.ng <dbl>,
## #   ref_amount_inject_measured.ng <dbl>, ref_amount_measured.ug <dbl>,
## #   yield <dbl>

check yields

calib_data %>% 
  select(file_id, peak_name, yield)  %>% 
  arrange(file_id)  %>% 
  unique() %>% 
  ggplot() + aes(file_id, y = yield) +
  geom_point(size = 3) +
  theme_bw() + theme(axis.text.x = element_text(angle = 90, hjust = 0, vjust = 0.5))
## Warning: Removed 2085 rows containing missing values (geom_point).

Combine compounds/make ratios (new rows w/o RTs etc, just concentration.rock column)

# functions to make it easy to sum up peaks

sum_peaks <- function(df, filter_condition, new_peak_name) {
  filter_condition <- sprintf("(%s)", str_c(filter_condition, collapse = "|"))
  filter(df, str_detect(peak_name, filter_condition)) %>% 
    summarize(
      file_id = file_id[1],
      depth = depth[1],
      conc_rock.ug_g = sum(conc_rock.ug_g)
    ) %>% 
    mutate(peak_name = new_peak_name)
}

ratio_peaks <- function(df, filter_top, filter_bottom, new_peak_name) {
  filter_top <- sprintf("(%s)", str_c(filter_top, collapse = "|"))
  filter_bottom <- sprintf("(%s)", str_c(filter_bottom, collapse = "|"))
  filter(df, str_detect(peak_name, filter_top) | str_detect(peak_name, filter_bottom)) %>% 
    summarize(
      file_id = file_id[1],
      depth = depth[1],
      ratio = sum(conc_rock.ug_g[str_detect(peak_name, filter_top)]) / sum(conc_rock.ug_g[str_detect(peak_name, filter_bottom)])
    ) %>% 
    mutate(peak_name = new_peak_name)
}

Ideas for other ratios? What about dimethyls?

#set values to use for later calculations
final_data1 <- calib_data %>% 
    group_by(file_id) %>% 
        do({
          bind_rows(., 
              #C27_Dia/Reg
                sum_peaks(.,  c("C27 aB 20R ST", "C27 aB 20S ST"), "C27Dia"),      
                sum_peaks(., c("C27 aaa 20R ST", "C27 aaa 20S ST", "C27 aBB 20R ST", "C27 aBB 20S ST", "C27 Ba 20R ST", "C27 Ba 20S ST"), "C27Reg"),
            
              #Total Tricyclics
                sum_peaks(., c("C19 Tri HO", "C20 Tri HO", "C21 Tri HO", "C22 Tri HO", "C23 Tri HO", "C24 Tet HO", "C24 Tri HO", "C25 Tri R HO", "C25 Tri S HO", "C26 Tri R HO", "C26 Tri S HO"), "all_tricyclics"),
            
              #4Me_TriMe
                sum_peaks(., c("4B Me 5a cholestane", "4B Me 24 ethyl 5a cholestane", "4B,23S,24S trimethyl 5a cholestane", "4B,23S,24R trimethyl 5a cholestane", "4B,23R,24S trimethyl 5a cholestane", "4B,23R,24R trimethyl 5a cholestane", "4a Me 5a cholestane", "4a Me 24 ethyl 5a cholestane", "4a,23S,24S trimethyl 5a cholestane", "4a,23S,24R trimethyl 5a cholestane", "4a,23R,24S trimethyl 5a cholestane", "4a,23R,24R trimethyl 5a cholestane"), "4Me_TriMe"),
            
              #allRegSt
                sum_peaks(., c("C26 aBB 20S ST", "C26 aBB 20R ST", "C26 aaa 20S ST", "C26 aaa 20R ST","C27 aBB 20S ST", "C27 aBB 20R ST", "C27 aaa 20S ST", "C27 aaa 20R ST", "C28 aBB 20S ST", "C28 aBB 20R ST", "C28 aaa 20S ST", "C28 aaa 20R ST","C29 aBB 20S ST", "C29 aBB 20R ST", "C29 aaa 20S ST", "C29 aaa 20R ST", "C30 aBB 20 R+S ST", "C30 aaa 20S ST", "C30 aaa 20R ST"), "allRegst"),
            
              #allRegHO
                sum_peaks(., c("Ts C27 HO", "Tm C27 HO", "C27 17B H Ho", "29, 30 C28H bisnor HO", "28, 30 C28 bisnor HO", "C29 Ts HO", "C29 Ba HO", "C29 BB Ho", "C30 aB HO", "C30 BB HO", "C30H Ba HO", "C31 HR Ba HO", "C31 aB HR HO", "C31 aB HS HO", "C31 BB HO", "C32 aB HS HO", "C32 aB HR HO", "C33 aB HS HO", "C33 aB HR HO", "C34 aB HR HO", "C34 aB HS HO", "C35 aB HR HO", "C35 aB HS HO"), "allRegHO") 
            
) }) %>% ungroup()
final_data <- final_data1 %>% 
    group_by(file_id) %>% 
        do({
          bind_rows(., 
           #Source
              #C19/tricyclics
                ratio_peaks(., "C19 Tri HO", "all_tricyclics", "C19/tricyclics"),
              #C20/tricyclics
                ratio_peaks(., "C20 Tri HO", "all_tricyclics", "C20/tricyclics"),
              #C21/tricyclics
                ratio_peaks(., "C21 Tri HO", "all_tricyclics", "C21/tricyclics"),
              #C22/tricyclics
                ratio_peaks(., "C22 Tri HO", "all_tricyclics", "C22/tricyclics"),
              #C23/tricyclics
                ratio_peaks(., "C23 Tri HO", "all_tricyclics", "C23/tricyclics"),
              #C24/tricyclics
                ratio_peaks(., c("C24 Tet HO", "C24 Tri HO"), "all_tricyclics", "C24/tricyclics"),
              #C25/tricyclics
                ratio_peaks(., c("C25 Tri R HO", "C25 Tri S HO"), "all_tricyclics", "C25/tricyclics"),
              #C26/tricyclics
                ratio_peaks(., c("C26 Tri R HO", "C26 Tri S HO"), "all_tricyclics", "C26/tricyclics"),
              #tricyclics/all
                ratio_peaks(., "all_tricyclics", c(""), "tricyclics/all"),
              #C19/C19+23
                ratio_peaks(., "C19 Tri HO", c("C19 Tri HO", "C23 Tri HO"), "C19/C19+23"),
              #C20/C20+23
                ratio_peaks(., "C20 Tri HO", c("C20 Tri HO", "C23 Tri HO"), "C20/C20+23"),
           
              #Ho/St
                ratio_peaks(., "allRegHO", c("C26 aaa 20S ST", "C26 aaa 20R ST", "C27 aaa 20S ST", "C27 aaa 20R ST", "C28 aaa 20S ST", "C28 aaa 20R ST", "C29 aaa 20S ST", "C29 aaa 20R ST", "C30 aaa 20S ST", "C30 aaa 20R ST"), "Ho/St"),
              #Ho/St%
                ratio_peaks(., "allRegHO", c("C26 aaa 20S ST", "C26 aaa 20R ST", "C27 aaa 20S ST", "C27 aaa 20R ST", "C28 aaa 20S ST", "C28 aaa 20R ST", "C29 aaa 20S ST", "C29 aaa 20R ST", "C30 aaa 20S ST", "C30 aaa 20R ST", "allRegHO" ), "Ho/St%"),
            
              #C31_2MHI
                ratio_peaks(., "C31 2a Me Ho", c("C30 aB HO", "C31 2a Me Ho" ), "C31_2MHI"),
              #C31_35_2MHI
                ratio_peaks(., c("C31 2a Me Ho", "C32 2aMe R HO", "C32 2aMe S HO", "C33 2aMe S HO", "C33 2aMe R HO", "C34 2a Me S HO", "C34 2a Me R HO", "C36 2a Me R HO", "C36 2a Me S HO"), c("C30 aB HO", "C31 2a Me Ho", "C32 2aMe R HO", "C32 2aMe S HO", "C33 2aMe S HO", "C33 2aMe R HO", "C34 2a Me S HO", "C34 2a Me R HO", "C36 2a Me R HO", "C36 2a Me S HO"), "C31_35_2MHI"),
              #C31_2-MHI/C27-C30Steranes
                ratio_peaks(., "C31 2a Me Ho", c("C26 aaa 20S ST", "C26 aaa 20R ST", "C27 aaa 20S ST", "C27 aaa 20R ST" ,"C28 aaa 20S ST", "C28 aaa 20R ST", "C29 aaa 20S ST", "C29 aaa 20R ST", "C30 aaa 20S ST", "C30 aaa 20R ST", "C31 2a Me Ho" ), "C31_2-MHI/C27-C30Steranes"),
              #C31 3-MHI 
                ratio_peaks(., "C31 3B Me HO", c("C31 3B Me HO", "C30 aB HO"), "C31 3-MHI"), 
              #C31_35_3MHI(%)
                 ratio_peaks(., c("C31 3B Me HO", "C32 3B Me S HO", "C32 3B Me R HO", "C32 3B Me Ba 22S+R ST", "C33 3BMe S HO", "   
C33 3BMe R HO", "C34 3B Me S Ho", "C34 3B Me R HO", "C35 3B Me R HO", "C35 3B Me S HO", "C36 3B Me S HO", "C36 3B Me R HO"), c("C30 aB HO","C31 3B Me HO", "C32 3B Me S HO", "C32 3B Me R HO", "C32 3B Me Ba 22S+R ST", "C33 3BMe S HO", "C33 3BMe R HO", "C34 3B Me S HO", "C34 3B Me R HO", "C35 3B Me R HO", "C35 3B Me S HO", "C36 3B Me S HO", "C36 3B Me R HO" ) ,"C31_35_3MHI(%)"),

              #C29ab/C29ab+C30ab
                 ratio_peaks(., "C29 aB HO", c( "C29 aB HO" , "C30 aB HO"), "C29ab/C29ab+C30ab"), 
              #C29ab/allHoab
                 ratio_peaks(., "C29 aB HO" , c("C35 aB HS HO", "C35 aB HR HO", "C34 aB HS HO", "C34 aB HR HO", "C33 aB HS HO" , "C33 aB HR HO", "C32 aB HR HO", "C32 aB HS HO", "C31 aB HS HO", "C31 aB HR HO", "C30 aB HO", "C29 aB HO"), "C29ab/allHoab"), 
              #C30ab/allHoab 
                 ratio_peaks(., "C30 aB HO" , c("C35 aB HS HO", "C35 aB HR HO", "C34 aB HS HO", "C34 aB HR HO", "C33 aB HS HO" , "C33 aB HR HO", "C32 aB HR HO", "C32 aB HS HO", "C31 aB HS HO", "C31 aB HR HO", "C30 aB HO", "C29 aB HO"), "C30ab/allHoab"), 
              #C31ab/allHoab 
                 ratio_peaks(., c("C31 aB HS HO", "C31 aB HR HO") , c("C35 aB HS HO", "C35 aB HR HO", "C34 aB HS HO", "C34 aB HR HO", "C33 aB HS HO" , "C33 aB HR HO", "C32 aB HR HO", "C32 aB HS HO", "C31 aB HS HO", "C31 aB HR HO", "C30 aB HO", "C29 aB HO"), "C31ab/allHoab"),
              #C32ab/allHoab 
                 ratio_peaks(., c("C32 aB HR HO", "C32 aB HS HO") , c("C35 aB HS HO", "C35 aB HR HO", "C34 aB HS HO", "C34 aB HR HO", "C33 aB HS HO" , "C33 aB HR HO", "C32 aB HR HO", "C32 aB HS HO", "C31 aB HS HO", "C31 aB HR HO", "C30 aB HO", "C29 aB HO"), "C32ab/allHoab"),
              #C33ab/allHoab 
                 ratio_peaks(., c( "C33 aB HS HO" , "C33 aB HR HO") , c("C35 aB HS HO", "C35 aB HR HO", "C34 aB HS HO", "C34 aB HR HO", "C33 aB HS HO" , "C33 aB HR HO", "C32 aB HR HO", "C32 aB HS HO", "C31 aB HS HO", "C31 aB HR HO", "C30 aB HO", "C29 aB HO"), "C33ab/allHoab"),
              #C34ab/allHoab 
                 ratio_peaks(., c( "C34 aB HS HO", "C34 aB HR HO") , c("C35 aB HS HO", "C35 aB HR HO", "C34 aB HS HO", "C34 aB HR HO", "C33 aB HS HO" , "C33 aB HR HO", "C32 aB HR HO", "C32 aB HS HO", "C31 aB HS HO", "C31 aB HR HO", "C30 aB HO", "C29 aB HO"), "C34ab/allHoab"),
              #C35ab/allHoab 
                 ratio_peaks(., c("C35 aB HS HO", "C35 aB HR HO") , c("C35 aB HS HO", "C35 aB HR HO", "C34 aB HS HO", "C34 aB HR HO", "C33 aB HS HO" , "C33 aB HR HO", "C32 aB HR HO", "C32 aB HS HO", "C31 aB HS HO", "C31 aB HR HO", "C30 aB HO", "C29 aB HO"), "C35ab/allHoab"),
              #OleananeIndex
                ratio_peaks(., "Oleanane HO", c("Oleanane HO", "C30 aB HO"), "OleananeIndex"),

              #HHI
                ratio_peaks(., c("C35 aB HS HO", "C35 aB HR HO") , c("C35 aB HS HO", "C35 aB HR HO", "C34 aB HS HO", "C34 aB HR HO", "C33 aB HS HO" , "C33 aB HR HO", "C32 aB HR HO", "C32 aB HS HO", "C31 aB HS HO", "C31 aB HR HO"), "HHI"),
              #C35/C35+C34
                ratio_peaks(., c("C35 aB HS HO", "C35 aB HR HO"), c("C34 aB HS HO", "C34 aB HR HO","C35 aB HS HO", "C35 aB HR HO"), "C35/C35+C34"),
              #GI
                ratio_peaks(., "gamma", c("gamma", "C30 aB HO"), "GI"),
              #28,30BNH/28,30BNH+C30
                ratio_peaks(., "28, 30 C28 bisnor HO", c("28, 30 C28 bisnor HO", "C30 aB HO"), "28,30BNH/28,30BNH+C30")
              
 ) }) %>% ungroup() 
  
final_data
## # A tibble: 14,699 x 35
##    file_id  peak_name  RT.min area.cpm height.cts    OG depth rock.g   tle
##    <chr>    <chr>       <dbl>    <dbl>      <dbl> <dbl> <dbl>  <dbl> <dbl>
##  1 TSQ3466… 20R 4a,24…   34.7    42909     396389  22.0   102   11.0  4.50
##  2 TSQ3466… 20R, 4a M…   33.4    33439     425331  22.0   102   11.0  4.50
##  3 TSQ3466… 20R, 4a M…   32.8    49529     763046  22.0   102   11.0  4.50
##  4 TSQ3466… 20R, 4a,2…   35.3    26212     404760  22.0   102   11.0  4.50
##  5 TSQ3466… 20S, 4a M…   32.1    49207     882869  22.0   102   11.0  4.50
##  6 TSQ3466… 20S, 4a,2…   35.8    31831     268610  22.0   102   11.0  4.50
##  7 TSQ3466… 20S, 4a,2…   34.0    51613     456842  22.0   102   11.0  4.50
##  8 TSQ3466… 25-nor C2…   37.6    11915     155542  22.0   102   11.0  4.50
##  9 TSQ3466… 28, 30 C2…   37.0    27403     343070  22.0   102   11.0  4.50
## 10 TSQ3466… 29, 30 C2…   35.8     5780      63220  22.0   102   11.0  4.50
## # ... with 14,689 more rows, and 26 more variables: maltene <dbl>,
## #   ref_amount_added.ug <dbl>, process <chr>, n_peaks <int>,
## #   n_standards <int>, ref_area.cpm <dbl>, amount.ug <dbl>,
## #   conc_rock.ug_g <dbl>, conc_tle.ug.g <dbl>, conc_maltene.ug.g <dbl>,
## #   calibration <chr>, data <list>, fit <list>, coefficients <list>,
## #   intercept <dbl>, intercept_se <dbl>, slope <dbl>, slope_se <dbl>,
## #   r2 <dbl>, total_volume.uL <dbl>, total_inject.uL <dbl>,
## #   ref_amount_inject_expected.ng <dbl>,
## #   ref_amount_inject_measured.ng <dbl>, ref_amount_measured.ug <dbl>,
## #   yield <dbl>, ratio <dbl>

Against depth

tricyclics

tri <- subset(final_data, peak_name %in% c("C19/tricyclics" , "C20/tricyclics" , "C21/tricyclics" , "C22/tricyclics" , "C23/tricyclics" , "C24/tricyclics" , "C25/tricyclics" , "C26/tricyclics")) %>%
  ggplot() +
  geom_area(mapping = aes(fill = peak_name)) +
  aes(x = depth, y = ratio, color = peak_name) +
  #facet_wrap(~peak_name, scales = "free") +
  scale_x_reverse() +
  coord_flip()
  
ggplotly(tri)
## Warning: Removed 120 rows containing missing values (position_stack).
tri_all <- subset(final_data, peak_name== "tricyclics/all") %>%
  ggplot() +
  aes(x = depth, y = ratio) +
  geom_point() +
  geom_smooth() +
  facet_wrap(~peak_name, scales = "free") +
  scale_x_reverse() +
  coord_flip()
ggplotly(tri_all)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 15 rows containing non-finite values (stat_smooth).
nineteen <- subset(final_data, peak_name== "C19/C19+23") %>%
  ggplot() +
  aes(x = depth, y = ratio) +
  geom_point() +
  geom_line() +
  facet_wrap(~peak_name, scales = "free") +
  scale_x_reverse() +
  coord_flip()
ggplotly(nineteen)
twenty <- subset(final_data, peak_name== "C20/C20+23") %>%
  ggplot() +
  aes(x = ratio, y = depth) +
  geom_point() +
  facet_wrap(~peak_name, scales = "free") +
  scale_y_reverse()
ggplotly(twenty)
subset(final_data, peak_name== "Ho/St") %>%
  ggplot() +
  aes(x = depth, y = ratio) +
  geom_point() +
  geom_line() +
  facet_wrap(~peak_name, scales = "free") +
  scale_x_reverse() +
  coord_flip()
## Warning: Removed 15 rows containing missing values (geom_point).
## Warning: Removed 15 rows containing missing values (geom_path).

subset(final_data, peak_name== "C31_2MHI") %>%
  ggplot() +
  aes(x = depth, y = ratio) +
  geom_point() +
  geom_line() +
  facet_wrap(~peak_name, scales = "free") +
  scale_x_reverse() +
  coord_flip()
## Warning: Removed 15 rows containing missing values (geom_point).
## Warning: Removed 15 rows containing missing values (geom_path).

subset(final_data, peak_name== "C31_35_2MHI") %>%
  ggplot() +
  aes(x = depth, y = ratio) +
  geom_point() +
  geom_line() +
  facet_wrap(~peak_name, scales = "free") +
  scale_x_reverse() +
  coord_flip()
## Warning: Removed 15 rows containing missing values (geom_point).
## Warning: Removed 15 rows containing missing values (geom_path).

subset(final_data, peak_name== "C31_2-MHI/C27-C30Steranes") %>%
  ggplot() +
  aes(x = ratio, y = depth) +
  geom_point() +
  facet_wrap(~peak_name, scales = "free") +
  scale_y_reverse()
## Warning: Removed 15 rows containing missing values (geom_point).

subset(final_data, peak_name== "C31 3-MHI") %>%
  ggplot() +
  aes(x = ratio, y = depth) +
  geom_point() +
  facet_wrap(~peak_name, scales = "free") +
  scale_y_reverse()
## Warning: Removed 15 rows containing missing values (geom_point).

subset(final_data, peak_name== "C31_35_3MHI(%)") %>%
  ggplot() +
  aes(x = ratio, y = depth) +
  geom_point() +
  facet_wrap(~peak_name, scales = "free") +
  scale_y_reverse()
## Warning: Removed 15 rows containing missing values (geom_point).

abs <- subset(final_data, peak_name== "C29ab/C29ab+C30ab") %>%
  ggplot() +
  aes(x = ratio, y = depth) +
  geom_point() +
  facet_wrap(~peak_name, scales = "free") +
  scale_y_reverse()
ggplotly(abs)
abho <- subset(final_data, peak_name== "C29ab/allHoab") %>%
  ggplot() +
  aes(x = depth, y = ratio) +
  geom_point() +
  geom_line() +
 # facet_wrap(~peak_name, scales = "free") +
  scale_x_reverse() +
  coord_flip()
ggplotly(abho)

ab/all ho

ho <- subset(final_data, peak_name %in% c("C30ab/allHoab", "C31ab/allHoab", "C32ab/allHoab", "C33ab/allHoab", "C34ab/allHoab", "C50ab/allHoab")) %>%
   ggplot() +
  geom_area(mapping = aes(fill = peak_name)) +
  aes(x = depth, y = ratio, color = peak_name) +
  #facet_wrap(~peak_name, scales = "free") +
  coord_flip() +
  scale_x_reverse() +
  scale_y_continuous() 
ggplotly(ho)
## Warning: Removed 75 rows containing missing values (position_stack).
subset(final_data, peak_name== "OleananeIndex") %>%
  ggplot() +
  aes(x = ratio, y = depth) +
  geom_point() +
  facet_wrap(~peak_name, scales = "free") +
  scale_y_reverse()
## Warning: Removed 15 rows containing missing values (geom_point).

subset(final_data, peak_name== "HHI") %>%
  ggplot() +
  aes(x = depth, y = ratio) +
  geom_point() +
  geom_line() +
  facet_wrap(~peak_name, scales = "free") +
  scale_x_reverse() +
  coord_flip()
## Warning: Removed 15 rows containing missing values (geom_point).
## Warning: Removed 15 rows containing missing values (geom_path).

subset(final_data, peak_name== "C35/C35+C34") %>%
  ggplot() +
  aes(x = depth, y = ratio) +
  geom_point() +
  geom_line() +
  facet_wrap(~peak_name, scales = "free") +
  scale_x_reverse() +
  coord_flip()
## Warning: Removed 15 rows containing missing values (geom_point).
## Warning: Removed 15 rows containing missing values (geom_path).

gi <- subset(final_data, peak_name== "GI") %>%
  ggplot() +
  aes(x = depth, y = ratio) +
  geom_point() +
  geom_line()+
  facet_wrap(~peak_name, scales = "free") +
  scale_x_reverse() +
  coord_flip()
ggplotly(gi)
subset(final_data, peak_name== "28,30BNH/28,30BNH+C30") %>%
  ggplot() +
  aes(x = ratio, y = depth) +
  geom_point() +
  facet_wrap(~peak_name, scales = "free") +
  scale_y_reverse()
## Warning: Removed 15 rows containing missing values (geom_point).